home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Graphics Plus
/
Graphics Plus.iso
/
general
/
visulztn
/
lise
/
minilise.lha
/
minilise
/
strings.h
< prev
next >
Wrap
Text File
|
1993-03-30
|
2KB
|
122 lines
/* -------------------------------------------
return position of a substring in a string
------------------------------------------- */
instr(substr,str)
char str[],substr[];
{
int i,p,flg,l1,l2;
l1=strlen(str); l2=strlen(substr);
for(p=0; p < l1; p++) {
flg=0;
for(i=0; i < l2; i++) {
if(str[p+i] != substr[i]) {
flg = -1; break;
}
}
if(flg == 0) return(p);
}
return(-1);
}
/* -------------------------------------------------
return a substring from within a mainstring
------------------------------------------------- */
midstr(substr,str,ss,es)
char substr[],str[];
int ss,es;
{
int i,j;
i=0;
for(j=ss; j <= es; j++) substr[i++]=str[j];
substr[i]=0;
return(0);
}
/* ---------------------------------------------------
return right hand end of a string
--------------------------------------------------- */
rightstr(substr,str,ss)
char substr[],str[];
int ss;
{
int l;
l=strlen(str); midstr(substr,str,ss,l-1);
return(0);
}
/* -----------------------------------------------------
return left hand side of a string
----------------------------------------------------- */
leftstr(substr,str,es)
char substr[],str[];
int es;
{
midstr(substr,str,0,es);
return(0);
}
/* -------------------------------------------------------
adjust string to the left, removing spaces
------------------------------------------------------- */
left(str)
char str[];
{
int i;
i=0;
while(str[i] == ' ') i++;
rightstr(str,str,i);
return(0);
}
/* -------------------------------------------------------
reverse a string
------------------------------------------------------- */
reverse(str)
char str[];
{
int l,n,i,c;
l=strlen(str)-1, n=l/2;
for(i=0; i <=n; i++) {
c=str[l-i]; str[l-i]=str[i]; str[i]=c;
}
return(0);
}
/* ------------------------------------------------------
compare two strings equating upper and lower case
------------------------------------------------------ */
lexcmp(str1,str2)
char str1[],str2[];
{
char s1[256],s2[256];
strcpy(s1,str1); strcpy(s2,str2);
strupc(s1); strupc(s2);
return(strcmp(s1,s2));
}
/* ---------------------------------------------
convert string to upper case
--------------------------------------------- */
strupc(str)
char str[];
{
int l,i;
l=strlen(str);
for(i=0; i < l; i++) str[i]=toupper(str[i]);
return(0);
}